package entity;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.ForceDiscriminator;
import org.hibernate.validator.NotNull;

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "activityType", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("activity")
@ForceDiscriminator
public class Activity {
	
	@Id
	@GeneratedValue
	private int id;
	
	@NotNull
	private String name;
	
	private String description;
	
	private boolean initialActivity;
	
	private boolean finalActivity;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@Cascade({CascadeType.ALL, CascadeType.DELETE_ORPHAN})
	private Activity nextActivity;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Process process;
	
	private String code;

	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	public void setInitialActivity(boolean initialActivity) {
		this.initialActivity = initialActivity;
	}

	public boolean isInitialActivity() {
		return initialActivity;
	}

	public void setFinalActivity(boolean finalActivity) {
		this.finalActivity = finalActivity;
	}

	public boolean isFinalActivity() {
		return finalActivity;
	}

	public void setNextActivity(Activity nextActivity) {
		this.nextActivity = nextActivity;
	}

	public Activity getNextActivity() {
		return nextActivity;
	}

	public void setProcess(Process process) {
		this.process = process;
	}

	public Process getProcess() {
		return process;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getCode() {
		return code;
	}
}
